 <script type="text/javascript">
    bkLib.onDomLoaded(function()
    {
        new nicEditor(
        {
            iconsPath: '<?php echo Utility::getSiteUrl()?>/public/images/nicEditorIcons.gif'
        }
            ).panelInstance('contentQuestion');
    });
</script>
<div id="main">
    <?php if($questionID==-1) $mode='save_new'; else $mode='update'; ?>
    <b>Điều hướng:</b>
    <br />
    [ <a href="<?php echo Utility::getSiteUrl(); ?>/managequestions/index">Giáo viên: <?php echo $lectureID;?></a> ]
    > [ <a href="<?php echo Utility::getSiteUrl(); ?>/managequestions/index/<?php echo $subjectID; ?>">Môn học: <?php echo $subjectID; ?></a> ]
    > [<a href="<?php echo Utility::getSiteUrl(); ?>/managequestions/index/<?php echo $subjectID; ?>/<?php echo $sectionID; ?>">Phần học: <?php echo $sectionID; ?></a> ]
    > [<b><a href="<?php echo Utility::getSiteUrl(); ?>/managequestions/index/<?php echo $subjectID; ?>/<?php echo $sectionID; ?>/<?php echo $questionID; ?>">Câu hỏi: <?php echo $questionID; ?></a></b> ]
    <br />
    <br />

    <?php if(isset($message)) echo "<center><font color=green><b>$message</b></font></center><br />"; ?>

    <form name="inputQuestion" id="inputQuestion" method='post' action="<?php echo Utility::getSiteUrl(); ?>/managequestions/<?php if($questionID ==-1)echo 'saveNewQuestion'; else echo'updateQuestion' ?>">

    <input type="hidden" name="lectureID" id="lectureID" value="<?php echo $lectureID; ?>">
    <input type="hidden" name="subjectID" id="subjectID" value="<?php echo $subjectID; ?>">
    <input type="hidden" name="sectionID" id="sectionID" value="<?php echo $sectionID; ?>">
    <?php if($questionID==-1); else{ ?>
    <input type="hidden" name="questionID" id="questionID" value="<?php echo $questionID; ?>">
    <?php } ?>
    <table border='1' width='500'>
        <tr>
            <td>Mã môn học: </td>
            <td><?php echo $subjectID; ?></td>
        </tr>
        <tr>
            <td>Mã phần học: </td>
            <td><?php echo $sectionID; ?></td>
        </tr>

        <tr>
            <td>Mã câu hỏi: </td>
            <td><?php if($questionID ==-1)echo 'chưa có'; else echo $question->id; ?></td>
        </tr>

        <tr>
            <td>Nội dung: </td>
            <td><textarea  name="contentQuestion" id="contentQuestion" rows="12" cols="120"><?php if($questionID !=-1)echo $question->content; else echo''?></textarea></td>
        </tr>
        <tr>
            <td>Trọng số: </td>
            <td>
            <select name="weightQuestion" id="weightQuestion">
                    <option value="1" <?php if($mode == 'update'){if($question->weight==1)echo 'select="selected"'; else echo '';} ?> >1</option>
                    <option value="2" <?php if($mode == 'update'){if($question->weight==2)echo 'select="selected"'; else echo '';} ?> >2</option>
                    <option value="3" <?php if($mode == 'update'){if($question->weight==3)echo 'select="selected"'; else echo '';} ?> >3</option>
                    <option value="4" <?php if($mode == 'update'){if($question->weight==4)echo 'select="selected"'; else echo '';} ?> >4</option>
            </select>
            </td>
        </tr>

        <tr>
            <td>Tải ảnh: </td>
            <td>
                <input type="button" value="thêm ảnh" onclick="window.open('<?php echo Utility::getSiteUrl(); ?>/upload ','Upload','menubar=no,width=800,height=500,toolbar=no')" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <center>
                    <input type="submit" value="<?php if($questionID !=-1)echo 'Cập nhật'; else echo'Lưu mới'?>">
                </center>
            </td>
        </tr>
    </table>
    </form>



    <br />
    <br />
    <?php
    if($questionID ==-1);
    else
    {
    ?>
    <b><a href="<?php echo Utility::getSiteUrl(); ?>/managequestions/index/<?php echo $subjectID; ?>/<?php echo $sectionID; ?>/<?php echo $questionID; ?>/-1">Thêm đáp án mới >>></a></b>
    <br />
    <br />
    <table border='1' width='500'>
    <thead>
        <tr>
                <th width='100'>Mã đáp án</th>
                <th width='100'>Mã câu hỏi</th>
                <th width='100'>Nội dung</th>
                <th width='100'>Đúng hay sai</th>
                <th width='100'>Thao tác</th>
        </tr>
    </thead>
    <tbody>
            <?php
            foreach($options as $option)
            {
                ?>
                <tr>
                    <td><center><?php echo $option->id; ?></center></td>
                    <td><center><?php echo $questionID; ?></center></td>
                    <td><center><textarea   rows="2" cols="20"><?php echo $option->content; ?></textarea></center></td>
                    <td><center><?php echo $option->trueorfalse; ?></center></td>
                    <td>
                        <center>
                        <a href="<?php echo Utility::getSiteUrl(); ?>/managequestions/index/<?php echo $subjectID; ?>/<?php echo $sectionID; ?>/<?php echo $questionID; ?>/<?php echo $option->id; ?>">sửa</a> | 
                        <a href="<?php echo Utility::getSiteUrl(); ?>/managequestions/deleteOption/<?php echo $lectureID; ?>/<?php echo $subjectID; ?>/<?php echo $sectionID; ?>/<?php echo $questionID; ?>/<?php echo $option->id; ?>" onClick="return confirmOfDeleting();" >xóa</a>
                        </center>
                    </td>
                </tr>
                <?php
            }
            ?>
    </tbody>
    </table>
    <?php
    }
    ?>
</div>